package com.xianzhi.dao;

import com.xianzhi.bean.Ad;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.sql.SQLException;

public class AdDaoImpl  implements AdDao{
    private SqlSessionFactory sqlSessionFactory;
    public AdDaoImpl(SqlSessionFactory sqlSessionFactory){
        this.sqlSessionFactory = sqlSessionFactory;
    }

    @Override
    public Ad findUserById(int id) throws SQLException {
        SqlSession sqlSession=   sqlSessionFactory.openSession();
       Ad ad=  sqlSession.selectOne("test.findUserById",id);
        sqlSession.close();
        return  ad;
    }
}
